package com.mikufufu.blog.service.impl;

import com.mikufufu.blog.utils.StringUtils;
import com.mikufufu.blog.mapper.RoleMapper;
import com.mikufufu.blog.model.entity.Role;
import com.mikufufu.blog.service.RoleService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

/**
 * 角色表 服务实现类
 * 
 */
@Service
public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements RoleService {

    @Override
    public String getCodeById(Integer roleId) {
        if (StringUtils.isEmpty(roleId)) {
            throw new RuntimeException("角色ID不能为空");
        }
        Role role = this.getById(roleId);
        if (StringUtils.isEmpty(role)) {
            throw new RuntimeException("角色不存在");
        }
        return role.getRoleCode();
    }
}
